package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.FlightDept;
import cn.wolfcode.luowowo.article.mapper.FlightDeptMapper;
import cn.wolfcode.luowowo.article.service.IFlightDeptService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Arrays;
import java.util.List;

@Service
public class FlightDeptServiceImpl implements IFlightDeptService {


    @Autowired
    private FlightDeptMapper flightDeptMapper;

    String[] abcde = {"A", "B", "C", "D", "E"};
    String[] FGHJ = {"F", "G", "H", "J"};
    String[] KLMNP = {"K", "L", "M", "N", "P"};
    String[] QRSTW = {"Q", "R", "S", "T", "W"};
    String[] XYZ = {"X", "Y", "Z"};


    @Override
    public void change() {
        List<String> a = Arrays.asList(abcde);

        List<String> f = Arrays.asList(FGHJ);
        List<String> k = Arrays.asList(KLMNP);
        List<String> q = Arrays.asList(QRSTW);
        List<String> x = Arrays.asList(XYZ);

        List<FlightDept> flightDept = flightDeptMapper.list();

        for (FlightDept dept : flightDept) {
            String one = dept.getPinyin().substring(0, 1);

            if (a.contains(one)) {
                dept.setDepartgroupId(1L);
                flightDeptMapper.updateByGroup(dept);
            }
            if (f.contains(one)) {
                dept.setDepartgroupId(2L);
                flightDeptMapper.updateByGroup(dept);
            }
            if (k.contains(one)) {
                dept.setDepartgroupId(3L);
                flightDeptMapper.updateByGroup(dept);
            }
            if (q.contains(one)) {
                dept.setDepartgroupId(4L);
                flightDeptMapper.updateByGroup(dept);
            }
            if (x.contains(one)) {
                dept.setDepartgroupId(5L);
                flightDeptMapper.updateByGroup(dept);
            }


        }


    }

    @Override
    public List<FlightDept> selectInitialA(long l) {


        return flightDeptMapper.finlA(l);
    }

    @Override
    public List<FlightDept> hotFlights() {

        return flightDeptMapper.finlIsHot();
    }


}